<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActionView::CompiledTemplates</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActionView::CompiledTemplates</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/rails/actionpack/lib/action_view/compiled_templates_rb.html">
                vendor/rails/actionpack/lib/action_view/compiled_templates.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Module
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
<a href="CompiledTemplates.html">CompiledTemplates</a> modules hold methods
that have been compiled. Templates are compiled into these methods so that
they do not need to be read and parsed for each request.
</p>
<p>
Each template may be compiled into one or more methods. Each method accepts
a given set of parameters which is used to implement local assigns passing.
</p>
<p>
To use a compiled template module, create a <a
href="CompiledTemplates.html#M001075">new</a> instance and include it into
the class in which you want the template to be rendered.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001080">compile_source</a>&nbsp;&nbsp;
      <a href="#M001078">compiled?</a>&nbsp;&nbsp;
      <a href="#M001076">full_key</a>&nbsp;&nbsp;
      <a href="#M001079">mtime</a>&nbsp;&nbsp;
      <a href="#M001075">new</a>&nbsp;&nbsp;
      <a href="#M001077">selector</a>&nbsp;&nbsp;
      <a href="#M001081">wrap_source</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">method_names</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M001075" class="method-detail">
        <a name="M001075"></a>

        <div class="method-heading">
          <a href="#M001075" class="method-signature">
          <span class="method-name">new</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001075-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001075-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/compiled_templates.rb, line 15</span>
15:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
16:       <span class="ruby-ivar">@method_names</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hash</span>, <span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
17:         <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-node">&quot;__compiled_method_#{(hash.length + 1)}&quot;</span>
18:       <span class="ruby-keyword kw">end</span>
19:       <span class="ruby-ivar">@mtimes</span> = {}
20:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001080" class="method-detail">
        <a name="M001080"></a>

        <div class="method-heading">
          <a href="#M001080" class="method-signature">
          <span class="method-name">compile_source</span><span class="method-args">(identifier, arg_names, source, initial_line_number = 0, file_name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Compile the provided source code for the given argument names and with the
given initial line number. The identifier should be unique to this source.
</p>
<p>
The file_name, if provided will appear in backtraces. If not provided, the
file_name defaults to the identifier.
</p>
<p>
This method will return the <a
href="CompiledTemplates.html#M001077">selector</a> for the compiled version
of this method.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001080-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001080-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/compiled_templates.rb, line 46</span>
46:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compile_source</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>, <span class="ruby-identifier">source</span>, <span class="ruby-identifier">initial_line_number</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">file_name</span> = <span class="ruby-keyword kw">nil</span>)
47:       <span class="ruby-identifier">file_name</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">identifier</span>
48:       <span class="ruby-identifier">name</span> = <span class="ruby-identifier">method_names</span>[<span class="ruby-identifier">full_key</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>)]
49:       <span class="ruby-identifier">arg_desc</span> = <span class="ruby-identifier">arg_names</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-value str">''</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;(#{arg_names * ', '})&quot;</span>
50:       <span class="ruby-identifier">fake_file_name</span> = <span class="ruby-node">&quot;#{file_name}#{arg_desc}&quot;</span> <span class="ruby-comment cmt"># Include the arguments for this version (for now)</span>
51:       
52:       <span class="ruby-identifier">method_def</span> = <span class="ruby-identifier">wrap_source</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">arg_names</span>, <span class="ruby-identifier">source</span>)
53:       
54:       <span class="ruby-keyword kw">begin</span>
55:         <span class="ruby-identifier">module_eval</span>(<span class="ruby-identifier">method_def</span>, <span class="ruby-identifier">fake_file_name</span>, <span class="ruby-identifier">initial_line_number</span>)
56:         <span class="ruby-ivar">@mtimes</span>[<span class="ruby-identifier">full_key</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>)] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
57:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>  <span class="ruby-comment cmt"># errors from compiled source</span>
58:         <span class="ruby-identifier">e</span>.<span class="ruby-identifier">blame_file!</span> <span class="ruby-identifier">identifier</span>
59:         <span class="ruby-identifier">raise</span>
60:       <span class="ruby-keyword kw">end</span>
61:       <span class="ruby-identifier">name</span>
62:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001078" class="method-detail">
        <a name="M001078"></a>

        <div class="method-heading">
          <span class="method-name">compiled?</span><span class="method-args">(identifier, arg_names)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="CompiledTemplates.html#M001077">selector</a>
</p>
        </div>
      </div>

      <div id="method-M001076" class="method-detail">
        <a name="M001076"></a>

        <div class="method-heading">
          <a href="#M001076" class="method-signature">
          <span class="method-name">full_key</span><span class="method-args">(identifier, arg_names)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Return the full key for the given identifier and argument names
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001076-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001076-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/compiled_templates.rb, line 23</span>
23:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">full_key</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>)
24:       [<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>]
25:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001079" class="method-detail">
        <a name="M001079"></a>

        <div class="method-heading">
          <a href="#M001079" class="method-signature">
          <span class="method-name">mtime</span><span class="method-args">(identifier, arg_names)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Return the time at which the method for the given identifier and argument
names was compiled.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001079-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001079-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/compiled_templates.rb, line 35</span>
35:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>)
36:       <span class="ruby-ivar">@mtimes</span>[<span class="ruby-identifier">full_key</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>)]
37:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001077" class="method-detail">
        <a name="M001077"></a>

        <div class="method-heading">
          <a href="#M001077" class="method-signature">
          <span class="method-name">selector</span><span class="method-args">(identifier, arg_names)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Return the <a href="CompiledTemplates.html#M001077">selector</a> for this
method or nil if it has not been compiled
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001077-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001077-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/compiled_templates.rb, line 28</span>
28:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">selector</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>)
29:       <span class="ruby-identifier">key</span> = <span class="ruby-identifier">full_key</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">arg_names</span>)
30:       <span class="ruby-identifier">method_names</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">key</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">method_names</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
31:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001081" class="method-detail">
        <a name="M001081"></a>

        <div class="method-heading">
          <a href="#M001081" class="method-signature">
          <span class="method-name">wrap_source</span><span class="method-args">(name, arg_names, source)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Wrap the provided source in a def &#8230; end block.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001081-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001081-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/compiled_templates.rb, line 65</span>
65:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wrap_source</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">arg_names</span>, <span class="ruby-identifier">source</span>)
66:       <span class="ruby-node">&quot;def #{name}(#{arg_names * ', '})\n#{source}\nend&quot;</span>
67:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>